package PartEdgeDemo;

import y.base.Graph;
import y.base.Node;
import y.base.NodeCursor;
import y.view.Graph2D;

/**
 * Created by IntelliJ IDEA.
 * User: zielke
 * Date: 9/29/11
 * Time: 11:29 AM
 * To change this template use File | Settings | File Templates.
 */
public class KxCreater {
  final int n;
  final Graph2D g;

  public KxCreater(int n, Graph2D g) {
    this.n = n;
    this.g = g;
  }

  public Graph2D create(){
    g.clear();
    for(int i=0;i<n;i++)
      createNodeCompletely(g,0,0);
    return g;
  }

  static Node createNodeCompletely(Graph2D g, double x, double y){
    Node node = g.createNode(x, y, String.valueOf(g.nodeCount() + 1));
    for(NodeCursor nc = g.nodes();nc.ok();nc.next()){
      Node curNode = nc.node();
      if(curNode == node)
        continue;
      g.createEdge(node, curNode);
    }
    return node;
  }
}
